package com.xdwanj.smartcity.data.repository;

import android.content.Context;

import androidx.lifecycle.LiveData;

import com.xdwanj.smartcity.App;
import com.xdwanj.smartcity.data.bean.BannerData;
import com.xdwanj.smartcity.data.bean.News;
import com.xdwanj.smartcity.data.repository.impl.HomeRepository;

import org.junit.Before;
import org.junit.Test;

import java.util.List;

public class IHomeRepositoryTest {

    private Context context;
    private HomeRepository repository;

    @Before
    public void setUp() throws Exception {
        context = App.context;
        HomeRepository.init();
        repository = HomeRepository.getInstance();
    }

    @Test
    public void listBannerByType() throws Exception {
        LiveData<List<BannerData>> data = repository.listBannerByType(2, 0, 0);
        Thread.sleep(1000);
        List<BannerData> value = data.getValue();
        for (BannerData bannerData : value) {
            System.out.println("bannerData = " + bannerData);
        }
    }

    @Test
    public void cancelByTag() {
    }

    @Test
    public void listNews() throws InterruptedException {
        LiveData<List<News>> data = repository.listNews("", null, "", "", "");
        Thread.sleep(1000);
        List<News> value = data.getValue();
        for (News news : value) {
            String json = App.gson.toJson(news);
            System.out.println("news = " + news);
            System.out.println("-------");
        }
    }
}